package com.example.controller;

import com.example.pojo.Messages;
import com.example.pojo.Result;
import com.example.service.MessagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/messages")
public class MessagesController {

    @Autowired
    private MessagesService messagesService;

    @GetMapping("/listBySenderId")
    public Result<List<Messages>> listBySenderId(@RequestParam Integer senderId) {
        List<Messages> messagesList = messagesService.listBySenderId(senderId);
        return Result.success(messagesList);
    }
}